import { ISkillDataType } from '../Skill/SkillBase';
/*
 * @features: 功能
 * @description: 说明
 * @Date: 2020-08-17 10:25:03
 * @Author: judu233(769471424@qq.com)
 * @LastEditTime: 2021-09-12 15:41:24
 * @LastEditors: judu233
 */

import SkillBase from "../Skill/SkillBase";

const { ccclass, property } = cc._decorator;

/**  
    * @Title : 新建类
    * @Description : 类说明
 **/
@ccclass
export default class SkillManager extends cc.Component {
    /**所有已加载的技能列表 */
    public skillMap: Map<string, ISkillDataType> = new Map();

    /**加载技能数据表 */
    public loadSkillTableData() {

    }

    /**根据id获取技能表数据 */
    public getSkillDataById(id: string) {
        let skill: SkillBase;
        try {
            let skillClassName: { new(): SkillBase; } = eval(id);
            skill = new skillClassName();
            //设置数据
            skill.data = this.skillMap.get(id);
            skill.initSkillData();
        } catch (error) {
            cc.error(`创建技能失败，id：${id},err: ${error}`);
        }
        return skill;
    }

    /**使用技能 */
    public useSkill(skill: SkillBase) { }

    /**升级技能 */
    public levelUpSkill(skill: SkillBase) { }

    /**降级技能 */
    public downgradeSkill(skill: SkillBase) { }

    /**冻结技能 */
    public frozenSkill(skill: SkillBase) { }
}
